<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>date方法技巧</title>
  </head>
  <body>
    <script>
      let now = new Date();
      console.log(now);

      const date = new Date();
      const y = date.getFullYear(),
        m = date.getMonth(),
        d = date.getDate();

      const list = [
        [new Date(y, m, d - date.getDay()), date],
        [new Date(y, m, 1), date],
        [new Date(y, m - 1, 1), new Date(y, m, 0)],
        [new Date(y, parseInt((m + 1) / 3) * 3, 1), date],
        m > 3
          ? [
              new Date(y, (parseInt((m + 1) / 3) - 1) * 3 - 1, 1),
              new Date(y, parseInt((m + 1) / 3) * 3, 0),
            ]
          : [(new Date(y - 1, 9, 1), new Date(y, 0, 0))],
        [new Date(y, 0, 1), date],
        [new Date(y - 1, 0, 1), new Date(y, 0, 0)],
      ];
      console.log(date.getDay());
    </script>
  </body>
</html>
